package com.zhongfl.crm.api.view;

import com.github.pagehelper.PageInfo;
import com.zhongfl.crm.model.LxDeliverOrder;
import com.zhongfl.crm.request.LxDeliverOrderRequest;
import com.zhongfl.crm.service.LxDeliverOrderService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.heptagram.core.common.rest.ResponseResult;

import javax.annotation.Resource;
import java.util.List;

/**
 * 励销交付订单api
 *
 * @author 奈良鹿丸
 * @date 2018/9/21
 */

@RestController
@RequestMapping("/LxDeliverOrder")
public class LxDeliverOrderController {

    @Resource
    private LxDeliverOrderService lxDeliverOrderService;

    /**
     * 按照客户订单ID查询对应的交付订单列表业务
     * @param lxCustomerOrderId
     * @return
     */
    @RequestMapping("/findLxDeliverOrderByLxCustomerId")
    public ResponseResult<List<LxDeliverOrder>> findLxDeliverOrderByLxCustomerId(Long lxCustomerOrderId){
        List<LxDeliverOrder> lxDeliverOrders = lxDeliverOrderService.findLxDeliverOrderByLxCustomerId(lxCustomerOrderId);
        return new ResponseResult<>(lxDeliverOrders);
    }


    /**
     * 分页查询所有的交付订单
     * @param lxDeliverOrderRequest
     * @return
     */
    @RequestMapping("/findLxDeliverOrderByPage")
    public ResponseResult<PageInfo<LxDeliverOrder>> findLxDeliverOrderByPage(@RequestBody LxDeliverOrderRequest lxDeliverOrderRequest){
        List<LxDeliverOrder> LxDeliverOrders = lxDeliverOrderService.findLxDeliverOrderByPage(lxDeliverOrderRequest);
        PageInfo<LxDeliverOrder> lxDeliverOrderPageInfo = new PageInfo<>(LxDeliverOrders);
        return new ResponseResult<>(lxDeliverOrderPageInfo);
    }


    /**
     * 按id查询交付订单详情
     */
    @RequestMapping("/findLxDeliverOrderById")
    public ResponseResult<LxDeliverOrder> findLxDeliverOrderById(Long id){
        LxDeliverOrder lxDeliverOrder = lxDeliverOrderService.findLxDeliverOrderById(id);
        return new ResponseResult<>(lxDeliverOrder);
    }
//
//    /**
//     * 按客户id查询对应的交付订单
//     */
//    @RequestMapping("findLxDeliverOrderByCustomerIds")
//    public ResponseResult<PageInfo<LxDeliverOrder>> findLxDeliverOrderByCustomerIds(@RequestBody LxDeliverOrderRequest lxDeliverOrderRequest){
//        List<LxDeliverOrder> LxDeliverOrders = lxDeliverOrderService.findLxDeliverOrderByCustomerIds(lxDeliverOrderRequest);
//        PageInfo<LxDeliverOrder> lxDeliverOrderPageInfo = new PageInfo<>(LxDeliverOrders);
//        return new ResponseResult<>(lxDeliverOrderPageInfo);
//    }

    /**
     * 按渠道id查询对应的交付订单
     */
    @RequestMapping("/findLxDeliverOrderByCustomerId")
    public ResponseResult<PageInfo<LxDeliverOrder>> findLxDeliverOrderByCustomerId(@RequestBody LxDeliverOrderRequest lxDeliverOrderRequest){
        List<LxDeliverOrder> LxDeliverOrders = lxDeliverOrderService.findLxDeliverOrderByCustomerId(lxDeliverOrderRequest);
        PageInfo<LxDeliverOrder> lxDeliverOrderPageInfo = new PageInfo<>(LxDeliverOrders);
        return new ResponseResult<>(lxDeliverOrderPageInfo);
    }
}
